#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int N, A, B;
struct Airline{
	int s, t;
	bool used;
}X[1010], Y[1010];

inline int calc(int len, Airline* s, int x){
	vector<pair<int, int> > V(0);
	for(int i=1; i<=len; i++){
		s[i].used = false;
		V.push_back(make_pair(s[i].s, i));
		V.push_back(make_pair(s[i].t, -i));
	}
	sort(V.begin(), V.end());
	int ret = 0, curr = x;
	for(int i=0; i<(int)V.size(); i++){
		if(V[i].second > 0){
			if(curr == 0)
				continue;
			-- curr;
			s[V[i].second].used = true;
			++ ret;
		}
		else{
			if(!s[-V[i].second].used)
				continue;
			++ curr;
		}
	}
	return ret;
}

int main(){
	freopen("airport.in", "r", stdin);
	freopen("airport.ans", "w", stdout);
	scanf("%d%d%d", &N, &A, &B);
	for(int i=1; i<=A; i++)
		scanf("%d%d", &X[i].s, &X[i].t);
	for(int i=1; i<=B; i++)
		scanf("%d%d", &Y[i].s, &Y[i].t);
	int ans = 0;
	for(int L=0; L<=N; L++)
		ans = max(ans, calc(A, X, L) + calc(B, Y, N-L));
	printf("%d", ans);
}
